#define _CRT_SECURE_NO_WARNINGS 1

////#include <stdio.h>
////
////struct S
////{
////	int i;
////	int arr[];
////};
////
////int main()
////{
////	struct S* ps = (struct S*)malloc(sizeof(struct S) + 5 * sizeof(int));
////	/*printf("%d\n", sizeof(struct S));
////	printf("%d\n", sizeof(ps));*/
////	if (ps == NULL)
////	{
////		perror("malloc");
////		return 1;
////	}
////	ps->i = 100;
////	int i = 0;
////	for (i = 0; i < 5; i++)
////	{
////		ps->arr[i] = i;
////	}
////	struct S* ptr = (struct S*)realloc(ps, sizeof(struct S) + 10 * sizeof(int));
////	if (ptr != NULL)
////	{
////		ps = ptr;
////	}
////	free(ps);
////	ps = NULL;
////	return 0;
////}
////#include <stdio.h>
////#include <stdlib.h>
////#include <assert.h>
////
////struct S
////{
////	int n;
////	int* arr;
////};
////
////int main()
////{
////	struct S* ps = (struct S*)malloc(sizeof(struct S));
////	assert(ps);
////	ps->arr = (int*)malloc(sizeof(int)* 5);
////	if (ps->arr == NULL)
////	{
////		return 1;         
////	}
////	ps->n = 100;
////	for (int i = 0; i < 5; i++)
////	{
////		ps->arr[i] = i;
////	}
////	int* ptr = (int*)realloc(ps->arr,10 * sizeof(int));
////	if (ptr != NULL)
////	{
////		ps->arr = ptr;
////	}
////	//use
////	free(ps->arr);
////	free(ps);
////	return 0;
////}
//#include <stdio.h>
//#include <stdlib.h>
//
//int main()
//{
//	int* p = (int*)calloc(10, sizeof(int));
//	if (p != NULL)
//	{
//		for (int i = 0; i < 10; i++)
//		{
//			printf("%d ", *(p + i));
//		}
//	}
//	free(p);
//	p = NULL;
//	return 0;
//}
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

int main()
{
	int** pp = (int**)malloc(3 * sizeof(int*));
	assert(pp);
	int i = 0;
	for (i = 0; i < 3; i++)
	{
		pp[i] = (int*)malloc(5 * sizeof(int));
		assert(pp[i]);
	}
	for (i = 0; i < 3; i++)
	{
		int j = 0;
		for (j = 0; j < 5; j++)
		{
			pp[i][j] = i + j + 1;
		}
	}
	for (i = 0; i < 3; i++)
	{
		int j = 0;
		for (j = 0; j < 5; j++)
		{
			printf("%d ", pp[i][j]);
		}
		printf("\n");
	}
	for (i = 0; i < 3; i++)
	{
		free(pp[i]);
		pp[i] = NULL;
	}
	free(pp);
	pp = NULL;
	return 0;
}